<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="referrer" content="never"> 
	<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<link rel="stylesheet" href="../../css/utils/mui.min.css" />
	<link rel="stylesheet" href="../../css/utils/toastr.min.css" />
	<title></title>
	<style>
		body {
			padding: 0;
			margin: 0;
			font-family: "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
			font-size: 14px;
			background-color: #fff;
		}
		.content {
			/*padding: 15px;*/
			margin-bottom: 70px;
		}
		.font-theme {
			color: #11B5AB;
		}
		.article-iframe {
			width: 100%;
			height: 100%;
		}
		.red-packet {
			display: none;
			position: absolute;
			top: 56px;
			right: 20px;
		}
		.red-packet img {
			width: 48px;
		}
		.article-body {
			margin: 20px 0;
		}
		.article-body img {
			max-width: 100%;
			vertical-align: top;
		}
		.article-body video {
			max-width: 100%;
		}
		.wechat-qrcode {
			width: 168px;
			height: 162px;
			margin: 0 auto;
			margin-top: 30px;
			padding-top: 79px;
			background: url(../../img/phone/wechat-qrcode.png) no-repeat;
			background-size: 100% 100%;
		}
		.wechat-qrcode .qrcode {
			width: 70px;
			height: 70px;
			margin: 0 auto;
			background-color: #fff;
		}
		.wechat-qrcode .qrcode img {
			width: 100%;
			height: 100%;
		}
		.article-operate {
			margin-top: 20px;
			display: flex;
			display: -webkit-flex;
			justify-content: space-between;
		}
		.article-like img {
			width: 25px;
			height: 25px;
			margin-right: 8px;
			vertical-align: middle;
		}
		.article-like span {
			color: #656565;
			vertical-align: bottom;	
		}
		.article-like.active span {
			color: #11B5AB;
		}
		.article-btn .mui-btn-outlined {
			padding: 2px 18px;
			border-radius: 20px;
		}
		
		.btn-theme {
			color: #11B5AB;
			border-color: #11B5AB;
		}
		.btn-theme:active {
			color: #fff;
			background-color: #11B5AB !important;
		}
		.merge-user-item {
			display: none;
			position: relative;
			display: table-cell;
			vertical-align: middle;
			padding-left: 10px;
			-webkit-flex: 1;
			-moz-box-flex: 1;
			-ms-flex: 1;
			flex: 1;
			height: 50px;
		}
		.user-item {
			position: relative;
			display: table-cell;
			vertical-align: middle;
			padding-left: 10px;
			-webkit-flex: 1;
			-moz-box-flex: 1;
			-ms-flex: 1;
			flex: 1;
			height: 50px;
		}
		.head-img {
			position: absolute;
			top: -20px;
			width: 55px;
			height: 55px;
			padding: 1px;
			border-radius: 50%;
			background-color: #fff;
		}
		.head-img img {
			width: 100%;
			height: 100%;
			border-radius: 50%;
		}
		.icon-item {
			display: table-cell;
			width: 50px;
			height: 50px;
			border-left: 1px solid #CBCBCB;
			vertical-align: middle;
 		   	text-align: center;
		}
		.icon-item img {
			margin-top: 5px;
			width: 20px;
			height: 20px;
		}
		.user-info {
			margin-left: 65px;
			color: #333;
		}
		.user-info .name {
			margin-right: 10px;
		}
		.user-info .position {
			font-size: 12px;
			color: #666666;
		}
		.user-info .phone {
			font-size: 13px;
		}
		
		.title-item {
			display: table-cell;
			-webkit-flex: 1;
			-moz-box-flex: 1;
			-ms-flex: 1;
			flex: 1;
			vertical-align: middle;
			padding-left: 10px;
			color: #333;
		}
		.btn-item {
			width: 120px;
			display: table-cell;
			text-align: center;
		}
		.btn-item button {
			width: 100px;
		}
		.merge-qrcode-item {
			display: none;
		}
		.card-tab {
			display: none;
		}
		.enroll-tab {
			display: none;
		}
		.tickets-tab {
			display: none;
		}
		.goods-tab {
			display: none;
		}
		.vouchers-tab {
			display: none;
		}
		.discountCoupons-tab {
			display: none;
		}
		.merge-tab {
			display: none;
		}
		.merge-enroll-item {
			width: 100px;
			display: none;
		}
		.merge-ticket-item {
			display: none;
		}
		.merge-goods-item {
			display: none;
		}
		.merge-vouchers-item {
			display: none;
		}
		.merge-discountCoupons-item {
			display: none;
		}
		/*报名模版样式*/
		.signup-div {
			display: none;
			/*background-color: #11B5AB;*/
			position: fixed;
			top: 0px;
			bottom: 0px;
			left: 0px;
			right: 0px;
			z-index: 100;
			overflow-y: auto;
			background: url(../../img/phone/leave_back.png) no-repeat;
			background-size: 100% 100%;
		}
		.uiwm-preview-signbg {
		    width: 100%;
		    background-size: cover;
		    color: #fff;
		    text-align: center;
		    /*overflow: hidden;*/
		    position: absolute;
		}
		.uiwm-preview-signbg h3 {
		    margin-top: 25px;
		    margin-bottom: 11px;
		    font-size: 16px;
		    line-height: 1;
		}
		.uiwm-preview-signbg #signContentPreview {
			color: #fff;
		    table-layout: fixed;
		    word-break: break-all;
		    overflow: hidden;
		    padding: 0 10px;
		    font-size: 14px;
		}
		.uiwm-preview-signbg .signForm {
		    margin: 12px;
		    margin-top: 20px;
		}
		/*.uiwm-preview-signbg .signForm input {
			display: inline-block;
			width: 128px;
			padding: 10px;
		    margin: 0;
		    height: 35px;
		    color: #fff;
		    border: 0;
		    vertical-align: middle;
    		background-color: transparent;
		}
		.uiwm-preview-signbg .signForm input::-webkit-input-placeholder { 
		}
		
		.uiwm-preview-signbg .signForm input::-moz-placeholder { 
		  color: #fff;
		}
		
		.uiwm-preview-signbg .signForm input:-ms-input-placeholder { 
		  color: #fff;
		} */
		.getVerifyCode {
		    display: none;
		    position: relative;
		}
		.getVerifyCode span {
		    font-size: 12px;
		    position: absolute;
		    right: 10px;
		    top: 7px;
		    z-index: 10000000;
		    color: #5a93f3;
		    cursor: pointer;
		}
		.uiwm-preview-signbg .signForm textarea {
			color: #333333;
		    height: 230px;
		    margin-bottom: 16.5px;
		    border: 0;
		    font-size: 12px;
		    border-radius: 4px;
		}
		.sign-btn {
			margin: 45px 18px 30px 18px;
		}
		.uiwm-preview-signbg .signForm .btn-warning {
			font-size: 16px;
		    background-color: #fff;
		    margin-bottom: 20px;
		    padding: 8px 12px;
		    color: #17D0AE;
		}
		.uiwm-preview-signbg .signForm .btn-default {
			padding: 8px 12px;
		    color: #17D0AE;
		    font-size: 16px;
		    background-color: #fff;
		}
		.btn-block+.btn-block {
		    margin-top: 5px;
		}
		.btn-block {
		    display: block;
		    width: 100%;
		}
		.sign-input {
			margin-bottom: 10px;
			display: flex;
			justify-content:space-between;
		}
		.input-line {
			border-bottom: 1px solid #fff;
		}
		.input-line img {
			width: 22px;
			height: 22px;
			display: inline-block;
			vertical-align: middle;
		}
		
		.mui-input-group {
			color: #333333;
			margin-bottom: 20px;
			border-radius: 4px;
			font-size: 14px;
		}
		.mui-input-group:before {
			opacity: 0;
		}
		.mui-input-group:after {
			opacity: 0;
		}
		.mui-input-row label~input {
			font-size: 14px;
		}
		/*遮罩层*/
		.modal-backdrop {
			display: none;
			position: fixed;
		    top: 0;
		    bottom: 0;
		    left: 0;
		    right: 0;
		    background-color: #000;
		    z-index: 90;
		    transition: opacity 0.15s linear 0s;
		    opacity: 0.6;
		    overflow: hidden;
		}
		.user-qrcode {
			display: none;
			position: fixed;
			top: calc(50% - 120px);
			left: calc(50% - 120px);
			width: 240px;
			height: 240px;
			background-color: #fff;
			border-radius: 10px;
			z-index: 91;
		}
		.qrcode-prompt {
			margin-top: 15px;
			text-align: center;
		}
		.user-qrcode-img {
			margin: 0 auto;
			margin-top: 10px;
			width: 175px;
			height: 175px;
		}
		.user-qrcode-img img {
			width: 100%;
			height: 100%;
		}
		.red-prompt {
			padding: 25px;
			color: #333;
		}
		.link-div {
			display: none;
		}
		.company-qrcode {
			display: none;
			position: fixed;
			top: calc(50% - 120px);
			left: calc(50% - 120px);
			width: 240px;
			height: 240px;
			background-color: #fff;
			border-radius: 10px;
			z-index: 91;
		}
		.company-qrcode-img {
			margin: 0 auto;
			margin-top: 10px;
			width: 175px;
			height: 175px;
		}
		.company-qrcode-img img {
			width: 100%;
			height: 100%;
		}
		#iframePage {
			display: none;
		}
	</style>
</head>
<body>
	<div class="content">
		<a class="red-packet" href="#redPopover">
			<img src="../../img/phone/red-packet.png" />
		</a>
		<div class="article-iframe">
			<iframe src="" id="iframePage" frameborder="0" scrolling="yes" marginwidth="0" marginheight="0" style="height: 700px;width: 100%;"></iframe>
		</div>
		<!--<div class="wechat-qrcode">
			<div class="qrcode"><img id="compamyQRCode" src="../../img/phone/qrcode.jpg" /></div>
		</div>-->
		<div class="article-operate">
			<div class="article-like">
				<img src="../../img/phone/article-like.png" /><span>0</span>
			</div>
			<!--<div class="article-btn">
				<button type="button" class="mui-btn mui-btn-outlined btn-theme">
					留言
				</button>
			</div>-->
		</div>
	</div>
	<!--名片插件管理-->
	<nav class="mui-bar mui-bar-tab card-tab">
		<div class="user-item">
			<!--<a class="head-img">
				<img src="../../img/login/logo.png" />	
			</a>
			<div class="user-info">
				<span class="name"></span><span class="position"></span><br />
				<a class="phone" href="tel:"></a>
			</div>-->
		</div>
		<div class="icon-item qrcode-item customer-wechat-click">
			<img src="../../img/phone/wechat-icon.png" />
		</div>
		<a class="icon-item phone-item customer-phone-click" href="#">
			<img src="../../img/phone/phone-icon.png" />
		</a>
	</nav>
	<!--报名-->
	<nav class="mui-bar mui-bar-tab enroll-tab">
		<div class="title-item">
		</div>
		<div class="btn-item">
			<button type="button" class="mui-btn btn-theme">立即报名</button>
		</div>
	</nav>
	<!--门票-->
	<nav class="mui-bar mui-bar-tab tickets-tab">
		<div class="title-item">
		</div>
		<div class="btn-item">
			<button type="button" class="mui-btn btn-theme">立即领票</button>
		</div>
	</nav>
	<!--商品-->
	<nav class="mui-bar mui-bar-tab goods-tab">
		<div class="title-item">
		</div>
		<div class="btn-item">
			<button type="button" class="mui-btn btn-theme">去购买</button>
		</div>
	</nav>
	<!--代金券-->
	<nav class="mui-bar mui-bar-tab vouchers-tab">
		<div class="title-item">
		</div>
		<div class="btn-item">
			<button type="button" class="mui-btn btn-theme">立即领取</button>
		</div>
	</nav>
	<!--打折券-->
	<nav class="mui-bar mui-bar-tab discountCoupons-tab">
		<div class="title-item">
		</div>
		<div class="btn-item">
			<button type="button" class="mui-btn btn-theme">立即领取</button>
		</div>
	</nav>
	<!--名片和报名-->
	<nav class="mui-bar mui-bar-tab merge-tab">
		<div class="merge-user-item">
			<!--<a class="head-img">
				<img src="../../img/login/logo.png" />	
			</a>
			<div class="user-info">
				<span class="name">用户名字</span><span class="position">销售总监</span><br />
				<a class="phone" href="tel:18685306265">18685306265</a>
			</div>-->
		</div>
		<div class="icon-item merge-qrcode-item customer-wechat-click">
			<img src="../../img/phone/wechat-icon.png" />
		</div>
		<div class="icon-item merge-enroll-item">
			<!--<span class="font-theme">报名</span>-->
		</div>
		<div class="icon-item merge-ticket-item">
			<!--<span class="font-theme">领票</span>-->
		</div>
		<div class="icon-item merge-goods-item">
			<!--<span class="font-theme">购买</span>-->
		</div>
		<div class="icon-item merge-vouchers-item">
			<!--<span class="font-theme">领代金券</span>-->
		</div>
		<div class="icon-item merge-discountCoupons-item">
			<!--<span class="font-theme">领打折券</span>-->
		</div>
	</nav>
	<div class="signup-div" id="enrollDiv">
		<div class="uiwm-preview-signbg" id="previewForm">
			<h3 id="signTitlePreview"></h3>
			<p id="signContentPreview"></p>
			<div class="signForm">
				<p class="getVerifyCode" style="display: none;">
					<input type="text" placeholder="请输入您的验证码" class="form-control input-sm"><span>获取验证码</span>
				</p>
				<div class="mui-input-group">
					<div class="mui-input-row">
						<label>姓名</label>
						<input id="userName" type="text" placeholder="请输入姓名">
					</div>
					<div class="mui-input-row">
						<label>电话</label>
						<input id="phone" type="text" placeholder="请输入号码">
					</div>
					<!--<div class="mui-input-row">
						<label>村</label>
						<input id="village" type="text" placeholder="请输入所在村">
					</div>
					<div class="mui-input-row">
						<label>组</label>
						<input id="groups" type="text" placeholder="请输入所在组">
					</div>
					<div class="mui-input-row">
						<label>种植面积</label>
						<input id="plant" type="text" placeholder="请输入种植面积">
					</div>-->
				</div>
				<textarea type="text" id="msgPreview" placeholder="留言" class="form-control input-sm"></textarea>
				<!--<div class="sign-input">
					<div class="input-line">
						<img src="../../img/phone/user-input.png" />
						<input id="userName" type="text" placeholder="姓名" class="form-control input-sm">
					</div>
					<div class="input-line">
						<img src="../../img/phone/phone-input.png" />
						<input id="phone" type="text" placeholder="电话" class="form-control input-sm">
					</div>
				</div>-->
				<div class="sign-btn">
					<button id="confirmSign" class="btn btn-block btn-warning" type="button">提交</button>
					<button class="btn btn-block btn-default back-article" type="button">返回原文</button>
				</div>
			</div>
		</div>
	</div>
	<!--代金券打折券领取-->
	<div class="signup-div" id="couponDiv">
		<div class="uiwm-preview-signbg">
			<h3 style="margin-top: 50px;">请填写您的姓名和号码领取券</h3>
			<div style="margin-top: 60px;" class="signForm">
				<div class="mui-input-group">
					<div class="mui-input-row">
						<label>姓名</label>
						<input id="couponName" type="text" placeholder="请输入姓名">
					</div>
					<div class="mui-input-row">
						<label>电话</label>
						<input id="couponPhone" type="text" placeholder="请输入号码">
					</div>
				</div>
				<div class="sign-btn">
					<button id="confirmCoupon" class="btn btn-block btn-warning" type="button">提交领取</button>
					<button class="btn btn-block btn-default back-article" type="button">返回原文</button>
				</div>
			</div>
		</div>
	</div>
	
	<div class="modal-backdrop"></div>
	<div class="user-qrcode">
		<div class="qrcode-prompt">长按二维码加好友</div>
		<div class="user-qrcode-img"></div>
	</div>
	<div id="redPopover" class="mui-popover">
		<div class="mui-popover-arrow"></div>
		<div class="red-prompt"><!--七夕红包大派送，转发朋友、朋友圈领取红包~-->亲！请分享文章给好友（朋友群、朋友圈）领取红包哦~</div>
	</div>
	<div id="signupSucc" class="mui-popup-backdrop mui-active" style="display: none;">
		<div class="mui-popup mui-popup-in">
			<div class="link-div"></div>
			<div class="mui-popup-inner">
				<div class="mui-popup-text">成功</div>
			</div>
			<div class="mui-popup-buttons">
				<span class="mui-popup-button mui-popup-button-bold">确定</span>
			</div>
		</div>
	</div>
	<div class="company-qrcode">
		<div class="qrcode-prompt">长按二维码关注公众号领取门票</div>
		<div class="company-qrcode-img"></div>
	</div>
	<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
	<script type="text/javascript" src="../../js/utils/jquery-1.12.4.min.js" ></script>
	<script type="text/javascript" src="../../js/utils/mui.min.js" ></script>
	<script type="text/javascript" src="../../js/utils/regular.js" ></script>
	<script type="text/javascript">
		document.write('<script type="text/javascript" src="../../js/utils/boot.js?v='+new Date().getTime()+'" ><\/script>');
	</script>
	<script>
		var userID,companyID,articleID,pluginID,customerID,readID,vouchersType,vouchersID,goodsID;
		$(function(){
			articleID = base.getParameter("articleID");
			userID = base.getParameter("userID");
			companyID = base.getParameter("companyID");
			customerID = base.getParameter("customerID");
			readID = base.getParameter("readID");
			taskUserId = base.getParameter("taskUserId");
			var parentID = base.getParameter("parentID");
			base.postData(base.url.getArticleInfo, {userID:userID,companyID:companyID,articleID:articleID,customerID:customerID,taskUserId:taskUserId}, callbackGetArticleInfo);
			base.postData(base.url.addShareRead, {customerID:customerID, userID:userID, parentCustomerID:parentID, articleID:articleID}, function(data){
				console.info(data);
			});
			var ifm= document.getElementById("iframePage");
			ifm.height=document.documentElement.clientHeight;
		});
		$.ajaxPrefilter(function (options) {
	        if (options.crossDomain && jQuery.support.cors) {
	            var http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
	            options.url = http + '//cors-anywhere.herokuapp.com/' + options.url;
	            //options.url = "http://cors.corsproxy.io/url=" + options.url;
	        }
	   });
		function initWX(title,desc,imgUrl,isRedPackage) {
			var url = server_root + "/phone/web/shareArticle.do" + window.location.search;
			var shareAppMessage = {
				title: title,
				desc: desc,
				link: url + "&type=1",
				imgUrl: imgUrl,
				success:function(){
					mui.toast("分享好友成功！");
					base.postData(base.url.addShareInfo, {userID:userID,companyID:companyID,articleID:articleID,customerID:customerID,type:1,taskUserId:taskUserId}, callbackAddShareInfo);
				},
				cancel:function(){
					mui.toast("取消分享！");
				}
			};
			var shareTimelineData = {
				title: title,
				desc: desc,
				link: url + "&type=2",
				imgUrl: imgUrl,
				success:function(){
					mui.toast("分享朋友圈成功！");
					base.postData(base.url.addShareInfo, {userID:userID,companyID:companyID,articleID:articleID,customerID:customerID,type:2,taskUserId:taskUserId}, callbackAddShareInfo);
				},
				cancel:function(){
					mui.toast("取消分享！");
				}
			};
			//初始化微信
			base.initWX(companyID, function () {
				wx.onMenuShareAppMessage(shareAppMessage);//微信好友
				wx.onMenuShareTimeline(shareTimelineData);//朋友圈
				if (isRedPackage == 1) {
					getLocation();	
				}
			});
		}
		function getLocation(){
			wx.getLocation({
				type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
				success: function (res) {
					var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
					var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
					var speed = res.speed; // 速度，以米/每秒计
					var accuracy = res.accuracy; // 位置精度
					console.log("经度："+longitude+"维度："+latitude);
					base.postData(base.url.updateCustomerInfo, {customerID:customerID,lon:longitude,lat:latitude}, callbackUpdateCustomerInfo);
				}
			});
		}
		function callbackUpdateCustomerInfo(data){
			if (data.success) {
				console.log(data.msg);
			}else{
				console.log(data.msg);
			}
		}
		function callbackAddShareInfo(data){
			if (data.success) {
				console.log(data.msg);
			}else{
				console.log(data.msg);
			}
		}
		function readTime(){
			base.postData(base.url.updateReadInfo, {userID:userID,readID:readID,readTime:10}, callbackUpdateReadInfo);
		}
		function callbackUpdateReadInfo(data){
			if (data.success) {
				console.log(data.msg);
			}else{
				console.log(data.msg);
			}
		}
		var interval = window.setInterval(readTime, 1000*10);
		//推文详情返回
		function callbackGetArticleInfo(data) {
			if (data.success) {
				//初始化微信
				initWX(data.context.articleTitle,data.context.articleAbstracts,data.context.articleImage,data.context.isRedPackage);
				$("title").text(data.context.articleTitle);
				data.context.companyWeChatQRCode && $("#compamyQRCode").attr("src", data.context.companyWeChatQRCode);
//				$("#articleTitle").text(data.context.articleTitle);
//				$(".user-article").html('<span class="font-theme">'+data.context.articleAuthor+'</span><span>'+data.context.articleAlterTime.substring(0,10)+'</span><br /><span>全文字数:'+data.context.articlewordNumber+'</span><span>预计阅读时长：'+data.context.articletotalTime+'s</span>');
//				$(".article-body").html(data.context.articleContent);
//				$("#iframePage").attr("src", data.context.contentsLink);
				if (data.context.contentsLink.indexOf("mp.weixin.qq.com") != -1) {
					$(".content").css("padding", "0px");
					$(".article-operate").css("padding", "15px");
			        $.get(
				        data.context.contentsLink,
				        function (response, status) {
				            if (status == "success") {
				            		$(".article-iframe").html(response);
				            } else {
				            		window.location.reload();
				            }
			        });
				} else {
					$(".content").css("padding", "15px");
					$(".article-operate").css("padding", "0px");
					$("#iframePage").show();
					$("#iframePage").attr("src", data.context.contentsLink);
				}
				if (data.context.isLike == 1) {
					$(".article-like").html('<img src="../../img/phone/article-like-active.png" /><span>'+data.context.likeNum+'</span>');
					$(".article-like").addClass("active");
				}else{
					$(".article-like").html('<img src="../../img/phone/article-like.png" /><span>'+data.context.likeNum+'</span>');	
				}
				if (data.context.isRedPackage == 1) {
					$(".red-packet").show();
					$("#redPopover .red-prompt").html(data.context.redPackDescribe);
				}
				//插件管理
				var plugLength = data.context.pluginList.length;
				if (plugLength == 0) {//没有插件
					$(".content").css("margin-bottom","0");
				}else if (plugLength == 1) {//一种插件
					//判断那种插件
					if (data.context.pluginList[0].pluginType == 0){//名片
						var card = data.context.pluginList[0].card;
						var html = '<a class="head-img customer-phone-click" href="tel:'+card.cardUserPhone+'">'+
									'	<img src="'+card.cardHeadImgUrl+'" />'+	
									'</a>'+
									'<div class="user-info">'+
									'	<input type="hidden" name="cardID" value="'+card.id+'" />'+
									'	<span class="name">'+card.cardUserName+'</span><span class="position">'+card.post+'</span><br />'+
									'	<a class="phone customer-phone-click" href="tel:'+card.cardUserPhone+'">'+card.cardUserPhone+'</a>'+
									'</div>';
						$(".card-tab .user-item").html(html);
						$(".card-tab .phone-item").attr("href","tel:"+card.cardUserPhone);
						$(".user-qrcode-img").html('<img src="'+card.wxQcImgUrl+'" />');
						$(".card-tab").css("display","table");
					} else if (data.context.pluginList[0].pluginType == 1) {//报名
						$(".content").css("margin-bottom","50px");
						pluginID = data.context.pluginList[0].pluginID;
						$(".enroll-tab .title-item").text(data.context.pluginList[0].enroll.activityTitle);
						$(".enroll-tab .btn-item button").text(data.context.pluginList[0].enroll.enrollButton);
						$("#signTitlePreview").text(data.context.pluginList[0].enroll.activityTitle);
						$("#signContentPreview").text(data.context.pluginList[0].enroll.activityDesp);
						$(".enroll-tab").css("display","table");
					} else if (data.context.pluginList[0].pluginType == 2) {//商品
						$(".content").css("margin-bottom","50px");
						goodsID = data.context.pluginList[0].pluginID;
						$(".goods-tab .title-item").text(data.context.pluginList[0].goods.title);
						$(".goods-tab").css("display","table");		
					} else if (data.context.pluginList[0].pluginType == 4) {//领票
						$(".content").css("margin-bottom","50px");
						pluginID = data.context.pluginList[0].pluginID;
						$(".tickets-tab .title-item").text(data.context.pluginList[0].activity.theme);
						$(".tickets-tab").css("display","table");
						if (data.context.companyWeChatQRCode) {
							$(".company-qrcode-img").html('<img src="'+data.context.companyWeChatQRCode+'" />');
						} else {
							$(".company-qrcode-img").html('<img src="../../img/phone/qrcode.jpg" />');
						}
					} else if (data.context.pluginList[0].pluginType == 3) {//代金券
						$(".content").css("margin-bottom","50px");
						var vouchers = data.context.pluginList[0].vouchers;
						$(".vouchers-tab .title-item").text("满"+(vouchers.fullRedPrice/100)+"减"+(vouchers.vouchersPrice/100)+"代金券");
						$(".vouchers-tab").append("<input type='hidden' name='vouchersID' value='"+data.context.pluginList[0].pluginID+"' />");
						$(".vouchers-tab").css("display","table");
					} else if (data.context.pluginList[0].pluginType == 5) {//打折券
						$(".content").css("margin-bottom","50px");
						var discountCoupons = data.context.pluginList[0].discountCoupons;
						$(".discountCoupons-tab .title-item").text(discountCoupons.discount+"折打折券");
						$(".discountCoupons-tab").append("<input type='hidden' name='vouchersID' value='"+data.context.pluginList[0].pluginID+"' />")
						$(".discountCoupons-tab").css("display","table");
					}
				}else if (plugLength > 1) {//一种以上插件
					var isCard = true;
					for (var i=0; i<data.context.pluginList.length; i++) {
						if (data.context.pluginList[i].pluginType==0) {
							isCard = false;
							$(".merge-tab .merge-user-item").css("display", "table-cell");
							$(".merge-tab .merge-qrcode-item").css("display", "table-cell");
							var card = data.context.pluginList[i].card;
							var html = '<a class="head-img customer-phone-click" href="tel:'+card.cardUserPhone+'">'+
										'	<img src="'+card.cardHeadImgUrl+'" />'+	
										'</a>'+
										'<div class="user-info">'+
										'	<input type="hidden" name="cardID" value="'+card.id+'" />'+
										'	<span class="name">'+card.cardUserName+'</span><span class="position">'+card.post+'</span><br />'+
										'	<a class="phone customer-phone-click" href="tel:'+card.cardUserPhone+'">'+card.cardUserPhone+'</a>'+
										'</div>';
							$(".merge-tab .merge-user-item").html(html);
							$(".user-qrcode-img").html('<img src="'+card.wxQcImgUrl+'" />');
						} else if (data.context.pluginList[i].pluginType==1) {
							pluginID = data.context.pluginList[i].pluginID;
							$(".merge-tab .merge-enroll-item").css("display", "table-cell");
							$(".merge-tab .merge-enroll-item").html('<span class="font-theme">报名</span>');
							$("#signTitlePreview").text(data.context.pluginList[i].enroll.activityTitle);
							$("#signContentPreview").text(data.context.pluginList[i].enroll.activityDesp);
						} else if (data.context.pluginList[i].pluginType==2) {
							goodsID = data.context.pluginList[i].pluginID;
							$(".merge-tab .merge-goods-item").css("display", "table-cell");
							$(".merge-tab .merge-goods-item").html('<span class="font-theme">购买</span>');	
						} else if (data.context.pluginList[i].pluginType==4) {
							pluginID = data.context.pluginList[i].pluginID;
							$(".merge-tab .merge-ticket-item").css("display", "table-cell");
							$(".merge-tab .merge-ticket-item").html('<span class="font-theme">领票</span>');
							if (data.context.companyWeChatQRCode) {
								$(".company-qrcode-img").html('<img src="'+data.context.companyWeChatQRCode+'" />');
							} else {
								$(".company-qrcode-img").html('<img src="../../img/phone/qrcode.jpg" />');
							}
						} else if (data.context.pluginList[i].pluginType==3) {//代金券
							pluginID = data.context.pluginList[i].pluginID;
							$(".merge-tab .merge-vouchers-item").css("display", "table-cell");
							$(".merge-tab .merge-vouchers-item").html('<span class="font-theme">领代金券</span>');
							$(".merge-tab .merge-vouchers-item").append("<input type='hidden' name='vouchersID' value='"+data.context.pluginList[i].pluginID+"' />")
						} else if (data.context.pluginList[i].pluginType==5) {//打折券
							pluginID = data.context.pluginList[i].pluginID;
							$(".merge-tab .merge-discountCoupons-item").css("display", "table-cell");
							$(".merge-tab .merge-discountCoupons-item").html('<span class="font-theme">领打折券</span>');
							$(".merge-tab .merge-discountCoupons-item").append("<input type='hidden' name='vouchersID' value='"+data.context.pluginList[i].pluginID+"' />")
						}
					}
					$(".merge-tab").css("display","table");
					if (isCard) {
						$(".merge-tab .merge-user-item").css("display","none");
					}
				}
			}
		}
		$("nav").on("click", ".customer-phone-click", function(){
			var cardID = $(this).closest("nav").find("input[name='cardID']").val();
			phoneWechatClick(cardID, 1);
		});
		$("nav").on("click", ".customer-wechat-click", function(){
			var cardID = $(this).closest("nav").find("input[name='cardID']").val();
			phoneWechatClick(cardID, 2);
		});
		function phoneWechatClick(cardID,type){
			var data = {
				userID:userID,
				companyID:companyID,
				articleID:articleID,
				customerID:customerID,
				cardID:cardID,
				type:type
			}
			base.postData(base.url.addCardCustomerInfo, data, callbackAddCardCustomerInfo);
		}
		function callbackAddCardCustomerInfo(data){
			if (data.success) {
				console.log(data.msg);
			}else{
				console.log(data.msg);
			}
		}
		$(".article-like").click(function(){
			if ($(this).attr("class").indexOf("active") != -1) {
				cancelLikeInfo();
			}else{
				addLikeInfo();
			}
		});
		//点赞
		function addLikeInfo(){
			var data = {
				userID:userID,
				companyID:companyID,
				articleID:articleID,
				customerID:customerID
			}
			base.postData(base.url.addLikeInfo, data, callbackAddLikeInfo);
		}
		function callbackAddLikeInfo(data){
			if (data.success) {
				$(".article-like").html('<img src="../../img/phone/article-like-active.png" /><span>'+data.context.likeNum+'</span>');
				$(".article-like").addClass("active");
			}else{
				mui.toast(data.msg);
			}
		}
		//取消点赞
		function cancelLikeInfo(){
			var data = {
				userID:userID,
				companyID:companyID,
				articleID:articleID,
				customerID:customerID
			}
			base.postData(base.url.cancelLikeInfo, data, callbackCancelLikeInfo);
		}
		function callbackCancelLikeInfo(data){
			if (data.success) {
				$(".article-like").html('<img src="../../img/phone/article-like.png" /><span>'+data.context.likeNum+'</span>');
				$(".article-like").removeClass("active");
			}else{
				mui.toast(data.msg);
			}
		}
		
		$(".qrcode-item").click(function(){
			$(".modal-backdrop").show();
			$(".user-qrcode").show();
		});
		$(".merge-qrcode-item").click(function(){
			$(".modal-backdrop").show();
			$(".user-qrcode").show();
		});
		$(".modal-backdrop").click(function(){
			$(".modal-backdrop").hide();
			$(".user-qrcode").hide();
			$(".company-qrcode").hide();
		});
		$(".merge-tab").on("click", ".merge-enroll-item", function() {
			$("#enrollDiv").show();
		})
		$(".merge-tab").on("click", ".merge-ticket-item", function() {
			//弹出公众号二维码
			var params = {
				ticketsID:pluginID,
				companyID:companyID,
				articleID:articleID,
				customerID:customerID,
				jumpUrl: window.location.href
			}
			base.postData(base.url.receiveTickets, params, function() {
				$(".modal-backdrop").show();
				$(".company-qrcode").show();
			});
		});
		$(".merge-tab").on("click", ".merge-goods-item", function() {
			window.location.href = "goodsDetail.html"+window.location.search+"&goodsID="+goodsID;
//			window.location.href = "goodsDetail.html?customerID="+customerID+"&companyID="+companyID+"&goodsID="+pluginID+"&articleID="+articleID;
		})
		//点击代金券
		$(".merge-tab").on("click", ".merge-vouchers-item", function() {
			$("#couponDiv").show();
			vouchersType = 1;
			vouchersID = $(this).find("input[name='vouchersID']").val();
		})
		//点击打折券
		$(".merge-tab").on("click", ".merge-discountCoupons-item", function() {
			$("#couponDiv").show();
			vouchersType = 2;
			vouchersID = $(this).find("input[name='vouchersID']").val();
		})
		$(".enroll-tab .btn-item").on("click", "button", function() {
			$("#enrollDiv").show();
		})
		$(".tickets-tab .btn-item").on("click", "button", function() {
			//弹出公众号二维码
			var params = {
				ticketsID:pluginID,
				companyID:companyID,
				articleID:articleID,
				customerID:customerID,
				jumpUrl: window.location.href
			}
			base.postData(base.url.receiveTickets, params, function() {
				$(".modal-backdrop").show();
				$(".company-qrcode").show();
			});
		})
		$(".goods-tab .btn-item").on("click", "button", function() {
			window.location.href = "goodsDetail.html"+window.location.search+"&goodsID="+pluginID;
//			window.location.href = "goodsDetail.html?customerID="+customerID+"&companyID="+companyID+"&goodsID="+pluginID+"&articleID="+articleID;
		})
		//点击代金券
		$(".vouchers-tab .btn-item").on("click", "button", function() {
			$("#couponDiv").show();
			vouchersType = 1;
			vouchersID = $(this).closest(".vouchers-tab").find("input[name='vouchersID']").val();
		});
		//点击打折券
		$(".discountCoupons-tab .btn-item").on("click", "button", function() {
			$("#couponDiv").show();
			vouchersType = 1;
			vouchersID = $(this).closest(".discountCoupons-tab").find("input[name='vouchersID']").val();
		});
		$(".signForm").on("click", ".back-article", function() {
			$(".signup-div").hide();
		})
		$(".signForm").on("click", "#confirmSign", function() {
			if ($("#userName").val() == null || $("#userName").val() == "") {
				mui.toast("姓名不能为空");
	        		return;
			}
			if (!checkPhone($("#phone").val())) {
				mui.toast("请输入正确的手机号码");
	        		return;
			}
			if ($("#msgPreview").val() == null || $("#msgPreview").val() == "") {
				mui.toast("留言不能为空");
	        		return;
			}
			var params = {
				articleID: articleID,
				enrollID: pluginID,
				companyID: companyID,
				userID: userID,
				customerID: customerID,
				phone: $("#phone").val(),
				username: $("#userName").val(),
//				village: $("#village").val(),
//				groups: $("#groups").val(),
//				plant: $("#plant").val(),
				enrollRemark: $("#msgPreview").val()
			}
			base.postData(base.url.addCustomerEnroll, params, callbackAddCustomerEnroll);
		})
		function callbackAddCustomerEnroll(data) {
			if (data.success) {
				$(".link-div").text(data.context.link);
				$("#signupSucc").show();
			} else {
				mui.toast(data.msg);
			}
		}
		//领取代金券打折券
		$(".signForm").on("click", "#confirmCoupon", function(){
			var name = $("#couponName").val();
			var phone = $("#couponPhone").val();
			if (name == null || name == "") {
				mui.toast("姓名不能为空");
        		return;
			}
			if (!checkPhone(phone)) {
				mui.toast("请输入正确的手机号码");
        		return;
			}
			var params = {
				userID:userID,
				customerID:customerID,
				companyID:companyID,
				vouchersID:vouchersID,
				vouchersType:vouchersType,
				name: name,
				phone: phone,
				contentsId: articleID
			}
			base.postData(base.url.addUserVouchers, params, function(data) {
				if(data.success) {
					$(".mui-popup-text").text(data.msg);
					$("#signupSucc").show();
					$("#couponName").val("");
					$("#couponPhone").val("");
				}else {
					mui.toast(data.msg);
				}
			});
		});
		$("#signupSucc").on("click", ".mui-popup-button-bold", function() {
			var _link = $(".link-div").text();
			if(_link){
				$(".signup-div").hide();
				window.location.href = _link;
			} else {
				$(".signup-div").hide();
			}
			$("#signupSucc").hide();
		})
	</script>
</body>
</html>
